<?php


namespace app\admin\model;

class Projects extends Base
{
    /**
     * $id 项目id
     * Desc: 获取项目进度
     * User: 苏鹏
     * Date: 2023/10/20
     * Time: 13:24
     * @return void
     */
    public function getProjectsSchedule(int $proj_id) :string
    {
        //项目下订单完成度
        $where = [
            'proj_id' => $proj_id,
            'status' => 1
        ];
        $finish_count = ProjectsOrder::where($where)->where('order_status', '=', 4)->count();
        $total_count = ProjectsOrder::where($where)->count();
        if(!empty($total_count))
        {
            $schedule = $finish_count/$total_count*100;
            $schedule = round($schedule, 0);
        }else{
            $schedule = 0;
        }
        return $schedule . '%';
    }
}